package com.IR.user.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import com.IR.shop.mapper.CollectsMapper;
import com.IR.shop.mapper.ProductMapper;
import com.IR.shop.po.Collects;
import com.IR.shop.po.Product;


@Service
public class ACollectsBiz {

	@Resource(name="collectsmapper")
	public CollectsMapper mapper;
	@Resource
	public ProductMapper mapper2;
	private Collects collects;
	private List<Collects> list;
	
	public List<Collects> getList() {
		return list;
	}
	public void setList(List<Collects> list) {
		this.list = list;
	}

	public Collects getCollects() {
		return collects;
	}
	public void setCollects(Collects collects) {
		this.collects = collects;
	}
	public void saveCollects(Long proid,Long userid) throws ParseException {
		
		Collects collects=new Collects();
		Date date = new Date();	
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String sss=format.format(date);		
		collects.setCdate(format.parse(sss));
		collects.setProid(proid);
		collects.setUserid(userid);
		Product p=new Product();
		p=mapper2.selectByPrimaryKey(proid);
		collects.setProname(p.getProname());
		collects.setProprice(p.getProprice());
		collects.setProimgs(p.getProimgs());
		mapper.insert(collects);
		
	}
	
	public void deleteCollects(int collectid) {
		mapper.deleteByPrimaryKey(collectid);
	}
	
	
}
